<?
set_time_limit(9999999);
/***************************************************************************

*                            Dolphin Smart Community Builder

*                              -----------------

*     begin                : Mon Mar 23 2006

*     copyright            : (C) 2006 BoonEx Group

*     website              : http://www.boonex.com/

* This file is part of Dolphin - Smart Community Builder

*

* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License. 

* http://creativecommons.org/licenses/by/3.0/

*

* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;

* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

* See the Creative Commons Attribution 3.0 License for more details. 

* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin, 

* see license.txt file; if not, write to marketing@boonex.com

***************************************************************************/
 
require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'languages.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );

echo "START .....<br /><br />";

echo "UPDATING DATABASE .....<br /><br />";
 
db_res("UPDATE `sys_modules` SET `version`='2.0.3' WHERE `uri` = 'location' AND `db_prefix` = 'modzzz_location_'");
  
db_res("
UPDATE `sys_menu_top` SET `Link` = CONCAT(`Link`, '|modules/?r=location/subreview/')  WHERE `Name`='Location' AND `Caption`='_modzzz_location_menu_root' AND  `Type` ='system' 
");
 
db_res("ALTER TABLE `modzzz_location_review` ADD `type` VARCHAR( 20 ) NOT NULL DEFAULT 'location'");  
  
db_res("UPDATE `modzzz_location_review` SET `type`='location'");  


db_res("INSERT INTO `sys_page_compose` (`Page`, `PageWidth`, `Desc`, `Caption`, `Column`, `Order`, `Func`, `Content`, `DesignBox`, `ColWidth`, `Visible`, `MinWidth`) VALUES 
    ('profile', '998px', 'Location I Been', '_modzzz_location_block_location_i_been', 2, 6, 'PHP', 'bx_import(''BxDolService''); return BxDolService::call(''location'', ''profile_been_block'', array(\$this->oProfileGen->_iProfileID));', 1, 66, 'non,memb', 0),
    ('profile', '998px', 'Location Reviews', '_modzzz_location_block_my_reviews', 2, 7, 'PHP', 'bx_import(''BxDolService''); return BxDolService::call(''location'', ''profile_reviews_block'', array(\$this->oProfileGen->_iProfileID));', 1, 66, 'non,memb', 0),

    ('modzzz_location_events_view', '998px', 'Location Event''s review block', '_modzzz_location_block_reviews', '2', '8', 'Review', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_shops_view', '998px', 'Location Shop''s review block', '_modzzz_location_block_reviews', '2', '8', 'Review', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_transports_view', '998px', 'Location Transport''s review block', '_modzzz_location_block_reviews', '2', '8', 'Review', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_foods_view', '998px', 'Location Food''s review block', '_modzzz_location_block_reviews', '2', '10', 'Review', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_hotels_view', '998px', 'Location Hotel''s review block', '_modzzz_location_block_reviews', '2', '8', 'Review', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_nightlifes_view', '998px', 'Location Nightlife''s review block', '_modzzz_location_block_reviews', '2', '10', 'Review', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_schools_view', '998px', 'Location School''s review block', '_modzzz_location_block_reviews', '2', '8', 'Review', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_services_view', '998px', 'Location Service''s review block', '_modzzz_location_block_reviews', '2', '8', 'Review', '', '1', '66', 'non,memb', '0') 
");

db_res("
INSERT INTO `sys_objects_actions` (`Caption`, `Icon`, `Url`, `Script`, `Eval`, `Order`, `Type`) VALUES 
     ('{TitleReview}', 'modules/modzzz/location/|action_review.png', '{evalResult}', '', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''subreview/event/{ID}'';', '2', 'modzzz_location_event'), 
     ('{TitleReview}', 'modules/modzzz/location/|action_review.png', '{evalResult}', '', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''subreview/shop/{ID}'';', '2', 'modzzz_location_shop'), 
     ('{TitleReview}', 'modules/modzzz/location/|action_review.png', '{evalResult}', '', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''subreview/transport/{ID}'';', '2', 'modzzz_location_transport'), 
     ('{TitleReview}', 'modules/modzzz/location/|action_review.png', '{evalResult}', '', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''subreview/school/{ID}'';', '2', 'modzzz_location_school'), 
     ('{TitleReview}', 'modules/modzzz/location/|action_review.png', '{evalResult}', '', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''subreview/food/{ID}'';', '2', 'modzzz_location_food'), 
     ('{TitleReview}', 'modules/modzzz/location/|action_review.png', '{evalResult}', '', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''subreview/hotel/{ID}'';', '2', 'modzzz_location_hotel'), 
     ('{TitleReview}', 'modules/modzzz/location/|action_review.png', '{evalResult}', '', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''subreview/nightlife/{ID}'';', '2', 'modzzz_location_nightlife'), 
     ('{TitleReview}', 'modules/modzzz/location/|action_review.png', '{evalResult}', '', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''subreview/service/{ID}'';', '2', 'modzzz_location_service') 
");


$iCategId = (int)db_value("SELECT `id` FROM  `sys_options_cats` WHERE `name`='Location'");
db_res("  
INSERT INTO `sys_options` (`Name`, `VALUE`, `kateg`, `desc`, `Type`, `check`, `err_text`, `order_in_kateg`, `AvailableValues`) VALUES  
('modzzz_location_perpage_reviews_profile', '4', $iCategId, 'Number of location reviews to show on profile page', 'digit', '', '', '0', ''),
('modzzz_location_perpage_members_profile', '4', $iCategId, 'Number of location members to show on profile page', 'digit', '', '', '0', '') 
");



$aSub = array('event', 'shop', 'hotel', 'nightlife', 'school', 'service', 'transport', 'food');
for ($item = 0; $item < count($aSub)-1; $item++) {

	$fields = mysql_list_fields($db['db'], "modzzz_location_" . $aSub[$item] . "_main"); 
	$columns = mysql_num_fields($fields);
		   
	for ($i = 0; $i < $columns; $i++) {
		$field_array[] = mysql_field_name($fields, $i);
	}
		   
	if (!in_array('zip', $field_array)) {
		db_res("ALTER TABLE `modzzz_location_" . $aSub[$item] . "_main` ADD `zip` VARCHAR( 20 ) NOT NULL");  
	}

}
  



echo "SUCCESSFULLY UPDATED DATABASE ..... <br /><br />";
 

echo "FINISHED <br />";


?>